<?php 

$category2 = PostCategory::model()->find('code_identifier = "tin_tuc"');
$dataPost2 = new CActiveDataProvider('Post', array(
    'criteria' => array(
        'order' => 'create_time DESC',
        'condition' => 'status = 1 AND category_id = '.$category2->id,                        
    ),
    'pagination' => array(
        'pageSize' => 10,
    ),                    
));

$category = PostCategory::model()->find('code_identifier = "huong_dan"');
$dataPost3 = new CActiveDataProvider('Post', array(
                    'criteria' => array(
                        'order' => 'create_time DESC',
                        'condition' => 'status = 1 AND category_id = '.$category->id,                        
                    ),
                    'pagination' => array(
                        'pageSize' => 10,
                    ),                    
                ));
$pcode = Yii::app()->request->getParam('pcode');
if(!isset($pcode)){ 
    $pcode = 'window';
}

$criteria = new CDbCriteria();
$criteria->select = 'game_platform.id, game_platform.game_id, game_platform.platform_id, game_platform.market_url, game_platform.bundle_id, game_platform.order';
$criteria->alias = 'game_platform';
$criteria->with = array('game'=>array('alias'  => 'game', 
                                        'select'=>'name,status,image,slug',
                                        'joinType'=> 'INNER JOIN' 
                                        ),
                        'platform'=>array('alias'  => 'platform', 
                                        'select'=>'name',
                                        'joinType'=> 'INNER JOIN' 
                                        )                    
                        );                 
//$criteria->join = "INNER JOIN game on game_platform.game_id = game.id";
//$criteria->join .= " INNER JOIN platform on game_platform.platform_id = platform.id";
$criteria->addCondition('game.status != 0');                
if($pcode != 'window'){
    $criteria->addCondition('platform.code_identifier ="'.$pcode.'"');
    $criteria->order = 'game_platform.order ASC';                    
}
$criteria->group = 'game_platform.game_id';
$model3 = new CActiveDataProvider('GamePlatform', array(
                        'criteria' => $criteria,
                        'pagination' => array(
                            'pageSize' => 16,
                        ),                    
                    ));   

?>
<div class="slide">
    <div class="main-page slide-content">
        <img alt="casino" src="<?php echo Yii::app()->createUrl('images/banner_1.png'); ?>"/>
    </div>
</div>

<div class="content-page">    
    <div class="main-box">
        <div class="main-page">   
            <div class="tab-panel-header">
                <ul class="tabBar col4" id="countrytabs">
                    <li class="tab"> <a rel="country1" onclick="$('#country1').html($('.listtintuc').html())" class="<?php if($dataPost->category_id == 2) echo 'selected'?>"><span>TIN TỨC</span></a> </li>    
                    <li class="tab"> <a rel="country2" onclick="$('#country2').html($('.listhuongdan').html())" class="<?php if($dataPost->category_id == 1) echo 'selected'?>"><span>HƯỚNG DẪN</span></a> </li>    
                    <li class="tab"> <a rel="country3" class=""><span>TẢI GAME</span></a> </li>
                    <li class="tab"> <a href="http://casino888.vn/forum/" target="_blank" rel="country4" class=""><span>DIỄN ĐÀN</span></a> </li>                
                </ul>
            </div> 
            <div class="wrapper-content">   
                <?php if($dataPost->category_id == 2): ?>
                <div class="listtintuc" style="display:none">      
                        <?php $this->widget('zii.widgets.CListView', array(
                                'dataProvider'=>$dataPost2,
                                'itemView'=>'_post_item',
                                'htmlOptions' => array('class' => 'wrapper-table'),  
                                'summaryText'=>'',
                                'emptyText' => 'Chưa có bài viết nào!'                
                                )); 
                        ?>
                </div>
                <div id="country1" class="tabcontent tintuc" style="display:block"> 
                    <div style="margin-bottom: 5px;">
                        <a href="/">Trang chủ</a> » <a onclick="$('#country1').html($('.listtintuc').html())">Tin tức - Sự kiện</a> » <span><?php echo strip_tags($dataPost->title); ?></span>
                    </div>
                    <!--<img alt="" width="30%" src="<?php echo Yii::app()->createUrl($dataPost->main_image);?>">-->
                    <div class="post-content" style="width:100%">
                        <div class="post-title"><h1><?php echo $dataPost->title; ?></h1></div><?php if($dataPost->hot == 1): ?><span><img src="<?php echo Yii::app()->createUrl('css/images/icon-hot-big.gif') ?>"/></span><?php endif;?>
                        <div class="post-date"><?php echo date('d/m/Y', strtotime($dataPost->create_time))?></div>
                        <div class="social">
                            <div style="float:left!important;">
                                <div class="g-plusone" style="padding-top: 4px !important;" data-size="Medium" data-href="<?php echo Yii::app()->createAbsoluteUrl($dataPost->getDetailLink()) ?>"></div>
                            </div>
                            <!-- Place this render call where appropriate -->
                            <script type="text/javascript">
                                (function() {
                                   var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
                                   po.src = 'https://apis.google.com/js/plusone.js';
                                   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
                                })();
                            </script>
                            <div id="fb-root"></div>                
                            <script>(function(d, s, id) {
                              var js, fjs = d.getElementsByTagName(s)[0];
                              if (d.getElementById(id)) return;
                              js = d.createElement(s); js.id = id;
                              js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=1401311996778175";
                              fjs.parentNode.insertBefore(js, fjs);
                            }(document, 'script', 'facebook-jssdk'));</script>
                            <div class="fb-like" style="margin: 0px 30px 0px 0px !important; width:50px !important; display: inline-block !important" data-href="<?php echo Yii::app()->createAbsoluteUrl($dataPost->getDetailLink()) ?>" data-width="50" data-layout="button_count" data-show-faces="false" <div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="standard" data-action="like" data-show-faces="false" data-share="true" data-send="false"></div>
                        </div>
                        <div class="post-sapo" style="clear: both;"><?php echo $dataPost->sapo ?></div>
                    </div>  
                    <div class="content" style="margin-top:5px;">
                    <?php $content = str_replace('../../files/posts/', '../files/posts/', $dataPost->content) ?>
                    <?php echo $content; ?>    
                    </div>
                    <div>
                        <span>Tags: </span>
                            <?php                         
                            $tags = explode(',', $dataPost->tags);
                            if(count($tags) > 0){
                                foreach($tags as $tag){
                                    $tag = strip_tags(trim(html_entity_decode($tag, ENT_QUOTES, 'UTF-8'), "\xc2\xa0"));
                                    echo '<a href="'.Yii::app()->createAbsoluteUrl('post/tags?tag='.$tag).'">'.$tag.'</a>,';
                                }
                            }                        
                            ?>
                    </div>

                    <div class="fb-comments" data-href="<?php echo Yii::app()->createAbsoluteUrl($dataPost->slug) ?>" data-numposts="10" data-colorscheme="light"></div>    

                    <div class="separator"><span>BÀI VIẾT KHÁC</span></div>
                    <?php if(isset($modelPostDiff)):?>
                    <ul class="category">
                        <?php foreach($modelPostDiff as $item):?>
                            <li><a href="<?php echo $item->getDetailLink() ?>"><?php echo $item->title ?></a></li>        
                        <?php endforeach;?>
                    </ul>    
                    <?php endif; ?>
                    </div>
                    <div id="country2" class="tabcontent listhuongdan" style="display:none">
                        <?php $this->widget('zii.widgets.CListView', array(
                                'dataProvider'=>$dataPost3,
                                'itemView'=>'_post_item',
                                'htmlOptions' => array('class' => 'wrapper-table'),  
                                'summaryText'=>'',
                                'emptyText' => 'Chưa có bài viết nào!'                
                                )); 
                        ?>
                    </div>
                    <?php else: ?>
                    <div id="country1" class="tabcontent listtintuc" style="display:none">      
                        <?php $this->widget('zii.widgets.CListView', array(
                                'dataProvider'=>$dataPost2,
                                'itemView'=>'_post_item',
                                'htmlOptions' => array('class' => 'wrapper-table'),  
                                'summaryText'=>'',
                                'emptyText' => 'Chưa có bài viết nào!'                
                                )); 
                        ?>
                    </div>
                    <div  class="listhuongdan" style="display:none">
                        <?php $this->widget('zii.widgets.CListView', array(
                                'dataProvider'=>$dataPost3,
                                'itemView'=>'_post_item',
                                'htmlOptions' => array('class' => 'wrapper-table'),  
                                'summaryText'=>'',
                                'emptyText' => 'Chưa có bài viết nào!'                
                                )); 
                        ?>
                    </div>
                    <div id="country2" class="tabcontent huongdan" style="display:block"> 
                    <div style="margin-bottom: 5px;">
                        <a href="/">Trang chủ</a> » <a onclick="$('#country2').html($('.listhuongdan').html())">Hướng dẫn</a> » <span><?php echo strip_tags($dataPost->title); ?></span>
                    </div>
                    <!--<img alt="" width="30%" src="<?php echo Yii::app()->createUrl($dataPost->main_image);?>">-->
                    <div class="post-content" style="width:100%">
                        <div class="post-title"><h1><?php echo $dataPost->title; ?></h1></div><?php if($dataPost->hot == 1): ?><span><img src="<?php echo Yii::app()->createUrl('css/images/icon-hot-big.gif') ?>"/></span><?php endif;?>
                        <div class="post-date"><?php echo date('d/m/Y', strtotime($dataPost->create_time))?></div>
                        <div class="social">
                            <div style="float:left!important;">
                                <div class="g-plusone" style="padding-top: 4px !important;" data-size="Medium" data-href="<?php echo Yii::app()->createAbsoluteUrl($dataPost->getDetailLink()) ?>"></div>
                            </div>
                            <!-- Place this render call where appropriate -->
                            <script type="text/javascript">
                                (function() {
                                   var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
                                   po.src = 'https://apis.google.com/js/plusone.js';
                                   var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
                                })();
                            </script>
                            <div id="fb-root"></div>                
                            <script>(function(d, s, id) {
                              var js, fjs = d.getElementsByTagName(s)[0];
                              if (d.getElementById(id)) return;
                              js = d.createElement(s); js.id = id;
                              js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=1401311996778175";
                              fjs.parentNode.insertBefore(js, fjs);
                            }(document, 'script', 'facebook-jssdk'));</script>
                            <div class="fb-like" style="margin: 0px 30px 0px 0px !important; width:50px !important; display: inline-block !important" data-href="<?php echo Yii::app()->createAbsoluteUrl($dataPost->getDetailLink()) ?>" data-width="50" data-layout="button_count" data-show-faces="false" <div class="fb-like" data-href="https://developers.facebook.com/docs/plugins/" data-layout="standard" data-action="like" data-show-faces="false" data-share="true" data-send="false"></div>
                        </div>
                        <div class="post-sapo" style="clear: both;"><?php echo $dataPost->sapo ?></div>
                    </div>  
                    <div class="content" style="margin-top:5px;">
                    <?php $content = str_replace('../../files/posts/', '../files/posts/', $dataPost->content) ?>
                    <?php echo $content; ?>    
                    </div>
                    <div>
                        <span>Tags: </span>
                            <?php                         
                            $tags = explode(',', $dataPost->tags);
                            if(count($tags) > 0){
                                foreach($tags as $tag){
                                    $tag = strip_tags(trim(html_entity_decode($tag, ENT_QUOTES, 'UTF-8'), "\xc2\xa0"));
                                    echo '<a href="'.Yii::app()->createAbsoluteUrl('post/tags?tag='.$tag).'">'.$tag.'</a>,';
                                }
                            }                        
                            ?>
                    </div>

                    <div class="fb-comments" data-href="<?php echo Yii::app()->createAbsoluteUrl($dataPost->slug) ?>" data-numposts="10" data-colorscheme="light"></div>    

                    <div class="separator"><span>BÀI VIẾT KHÁC</span></div>
                    <?php if(isset($modelPostDiff)):?>
                    <ul class="category">
                        <?php foreach($modelPostDiff as $item):?>
                            <li><a href="<?php echo $item->getDetailLink() ?>"><?php echo $item->title ?></a></li>        
                        <?php endforeach;?>
                    </ul>    
                    <?php endif; ?>
                    </div>
                    <?php endif;?>                                   
                    
                <div id="country3" class="tabcontent" style="display: none">
                    <?php $this->widget('zii.widgets.CListView', array(
                            'dataProvider'=>$model3,
                            'itemView'=>'_game_item',
                            'htmlOptions' => array('class' => 'wrapper-table'),  
                            'summaryText'=>'',
                            'emptyText' => 'Chưa có game nào!'                
                            )); 
                    ?>
                </div>
                <div id="country4" class="tabcontent" style="display:none">
                    
                </div>    
            </div>    
        </div>
          
    </div>
    <div class="left-box">
        <?php $this->widget('GamesWidget') ?> 
    </div>
</div>

